﻿using ServiceStack.ServiceInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenThesis.DTO.FX;
using OpenThesis.DTO.FX.Service;
using OpenThesis.FX;
using OpenThesis.Extensions.FX;

namespace OpenThesis.Rest.Services
{
	class FXService : Service
	{
		readonly ITradesRepository _tradesRepository;

		public FXService(ITradesRepository tratesRepository)
		{
			_tradesRepository = tratesRepository;
		}

		public List<Position> Get(Positions request)
		{
			// Check if we have been given a time
			var atTime = request.AtTime == DateTime.MinValue ? DateTime.Now : request.AtTime;

			return ServiceProvider.FX_Factory.BuildPositions(_tradesRepository.GetActiveTrades(request.Account, atTime));

		}
	}
}
